package day16.ZiXi.UDP.ZuBo;

import java.io.IOException;
import java.net.*;

public class ClinetDemo {
    public static void main(String[] args) throws IOException {
        //1. 创建发送端的Socket对象(DatagramSocket)
        DatagramSocket ds = new DatagramSocket();
        String s = "奥里给";
        byte[] bys = s.getBytes();
        InetAddress add = InetAddress.getByName("224.1.0.1");
        int port = 1000;
        //2. 创建数据，并把数据打包(DatagramPacket)
        DatagramPacket dp = new DatagramPacket(bys, bys.length, add, port);

        //3. 调用DatagramSocket对象的方法发送数据(在单播中,这里是发给指定IP的电脑但是在组播当中,这里是发给组播地址)
        ds.send(dp);

        //4. 释放资源
        ds.close();

    }
}